import Vue from 'vue'

// 第三方的全局css默认样式
import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App' // App
import store from './store' // vuex
import router from './router' // 路由文件

import '@/icons' // icon
import '@/permission' // permission control

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}

// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = false

// 全局过滤器，处理图片
Vue.filter('dalImg', (url) => {
  if (url) {
    if (url.startsWith('http')) {
      return url
    }
    return process.env.VUE_APP_BASE_API + url
  } else {
    return 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F14362514902%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1656580265&t=0ec38f20e00dbc2f3fd0a0cb8ef7b602'
  }
})
new Vue({
  el: '#app',
  router,
  store,
  render: (h) => h(App)
})
